﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="KARRParinguAndmed", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(KARRParinguAndmed))]
    public class KARRParinguAndmedSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKARRParinguAndmed clazz;
        
        public KARRParinguAndmedSerializer(IKARRParinguAndmed clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.EesmarkKL!=null) {
                Writer.WriteStartElement("EesmarkKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.EesmarkKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kommentaar!=null) {
                Writer.WriteStartElement("Kommentaar");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kommentaar))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ParinguTegemiseValitudAeg!=null) {
                Writer.WriteStartElement("ParinguTegemiseValitudAeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.ParinguTegemiseValitudAeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tasuline!=null) {
                Writer.WriteStartElement("Tasuline");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.Tasuline))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Salastatud!=null) {
                Writer.WriteStartElement("Salastatud");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.Salastatud))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AvalduseNR!=null) {
                Writer.WriteStartElement("AvalduseNR");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AvalduseNR))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Infosysteem!=null) {
                Writer.WriteStartElement("Infosysteem");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Infosysteem))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="EesmarkKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.EesmarkKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("EesmarkKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Kommentaar") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kommentaar = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Kommentaar")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ParinguTegemiseValitudAeg") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ParinguTegemiseValitudAeg = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("ParinguTegemiseValitudAeg")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Tasuline") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>KARRParinguAndmed>Tasuline");
                }
                clazz.Tasuline = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("Tasuline")).Value;
            }
            if (Reader.LocalName=="Salastatud") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>KARRParinguAndmed>Salastatud");
                }
                clazz.Salastatud = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("Salastatud")).Value;
            }
            if (Reader.LocalName=="AvalduseNR") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AvalduseNR = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AvalduseNR")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Infosysteem") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Infosysteem = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Infosysteem")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
